// 使用技术：vue-router4
// 基础路由：constantRouterMap
// 异步路由：asyncRouterMap
// modules中对应每个菜单路由数据，同级路由name不可冲突
// tenant-Admin交给后端添加 sys-admin前端写死
// 路由属性：hidden 路由显示/隐藏
//          alwaysShow 当children只有一个路由时，父菜单显示/隐藏

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
// import device from './modules/device'
// import fineReport from './modules/fineReport'
// import pipeLine from './modules/pipeLine'
import sysAdmin from './modules/sysAdmin'

import Layout from '@/views/layout/frame/Layout.vue'
import rtsp from './modules/rtsp'
import maintenance from './modules/maintenance'
import repair from './modules/repair'
import component from './modules/component'

export const constantRouterMap: Array<any> = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    props: route => ({ query: route.query.q }),
    children: []
  },
  { path: '/404', component: () => import('@/views/404.vue') },
  {
    path: '/',
    component: Layout
  },
  {
    path: '/accountManage',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        name: 'accountManage',
        component: () => import('@/views/accountManage/index.vue'),
        meta: { title: '账户管理', icon: 'form' }
      }
    ]
  },
  {
    path: '/application',
    component: Layout,
    hidden: true,
    meta: { roles: ['SYS_ADMIN'] },
    children: [
      {
        path: 'index',
        name: 'application',
        component: () => import('@/views/application/index.vue'),
        meta: { title: '应用管理', icon: 'form', roles: ['SYS_ADMIN'] }
      }
    ]
  }
]

export const asyncRouterMap: Array<any> = [
  // ...xunjianRouter,
  // ...testRouter,
  // ...shuiwu,
  // ...device,
  // ...pipeLine,
  ...rtsp,
  ...repair,
  ...maintenance,
  // ...component,
  ...sysAdmin
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes: constantRouterMap
})

export default router
